package com.buba.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.buba.service.SupplierManagementService;
import common.R;
import entity.system.SupplierManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.buba.service.SupplierManagementService;
import common.R;
import entity.system.SupplierManagement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 供应商管理信息表 前端控制器
 * </p>
 *
 * @author beisheng
 * @since 2023-05-18
 */
@RestController
@RequestMapping("/supplier-management")
public class SupplierManagementController {
    @Autowired
    private SupplierManagementService supplierManagementService;

    /**
     * @return common.R
     * @Author atlong
     * @Description //查询供应商列表信息
     * @Date 2023/6/5 14:57
     * @Param []
     **/
    @GetMapping("selAllSuppliers")
    public R selAllSuppliers() {
        List<SupplierManagement> list = supplierManagementService.selAllSuppliers();
        return R.success(list);
    }


    /* *
     * @Author: beisheng
     * @Descriprion: 根据供应商ID查询供应商
     * @Date: 2023/5/29 8:28
     * @Return: entity.system.SupplierManagement
     * @Param: [id]
     */

    @GetMapping("/selOneSuppById")
    public SupplierManagement selOneSuppById(@RequestBody Integer id){
        SupplierManagement supplierManagement = supplierManagementService.getById(id);
        return supplierManagement;
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 根据供应商ID查询供应商
     * @Date: 2023/5/29 8:28
     * @Return: entity.system.SupplierManagement
     * @Param: [id]
     */

    @GetMapping("/selOneSuppByIds/{id}")
    public R selOneSuppByIds(@PathVariable("id") Integer id){
        SupplierManagement supplierManagement = supplierManagementService.getById(id);
        return R.success(supplierManagement);
    }

    /* *
     * @Author: beisheng
     * @Descriprion: 查询全部供应商
     * @Date: 2023/6/5 15:39
     * @Return: common.R
     * @Param: []
     */

    @GetMapping("/selAllSupplier")
    public R selAllSupplier(){
        return R.success(supplierManagementService.list(new QueryWrapper<SupplierManagement>().eq("delete_flag",0)));
    }
}

